<!DOCTYPE html>
<html lang="zh">
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta charset="utf-8"/>
    <title>image-viewer</title>
    <style>
        
    </style>
</head>
<body>
    <div id="app">
        <button @click="prev">上一张</button>
        <button @click="next">下一张</button>
        <button @click="pickOne">random</button>
        <image-viewer v-bind="imageViewerProp"></image-viewer>   
    </div>
    <script type="text/javascript" src="../images/data.js"></script>
    <script type="text/javascript" src="../vue-2.5.17/dist/vue.js"></script>

    <script type="text/javascript" src="../components/base-view.js"></script>
    <link rel="stylesheet" href="../components/base-view.css">
    <script type="text/javascript" src="../components/scroll-view.js"></script>
    <link rel="stylesheet" href="../components/scroll-view.css">
    <script type="text/javascript" src="../components/smart-img.js"></script>

    <script type="text/javascript" src="./index.js"></script>
    <link rel="stylesheet" href="./index.css">
    <script>
        var i = parseInt(window.location.hash.slice(1));
        i = isNaN(i) ? Math.floor(Math.random() * list.length) : i % list.length;
        var vm = new Vue({
            el: '#app',
            data: {
                index: i,
                imageViewerProp: {

                    src: list[i],
                    width: 800,
                    height: 800,
                    viewWidth: 600,
                    viewHeight: 600
                }
                    
            },
            methods: {
                pickOne: function() {
                    this.index = Math.floor(Math.random() * list.length);
                    this.$set(this.imageViewerProp, 'src', list[this.index]);
                },
                next: function() {
                    this.index = (this.index + 1) % list.length;
                    this.$set(this.imageViewerProp, 'src', list[this.index]);

                },
                prev: function() {
                    this.index = (this.index - 1 + list.length) % list.length;
                    this.$set(this.imageViewerProp, 'src', list[this.index]);

                }
            }
        })
    </script>
</body>
</html>